package ecom.nopecom.steps.search;

import cucumber.annotation.After;
import cucumber.annotation.Before;
import cucumber.annotation.en.Given;
import cucumber.annotation.en.Then;
import cucumber.annotation.en.When;

import consumer.CheckOut;
import consumer.HomePage;
import consumer.SearchPage;
import ecom.nopecom.account.Login;
import ecom.nopecom.account.Registration;
import ecom.nopecom.util.ConsumerProvider;
import ecom.nopecom.util.NopComFactory;


public class SearchStepDefs {

	
	

	
	
HomePage hp=new HomePage();
SearchPage sp=new SearchPage();
Login loginPage = new Login();
ConsumerProvider consumerProvider = new ConsumerProvider();
   Registration registration = new Registration();
   CheckOut checkOut = new CheckOut();


@Before
public void loadDetails()
 {
    NopComFactory.getBrowser();
 }


	@Given("^user is in nopCommerce home page$")
	public void user_is_in_nopCommerce_home_page() {
hp.gotoHomepage();	  
	}

	@When("^user enters a product in search field$")
	public void user_enters_a_product_in_search_field() {
	    hp.searchforvalidproduct("computer");
	}

	@Then("^user should view the results$")
	public void user_should_view_the_results() {
	    sp.isResultShown();
	}

	@Then("^the results should contain the given product$")
	public void the_results_should_contain_the_given_product() {
	    sp.isProductShown("computer");

}
	
	

	@After
	public void tearDown()
	{
		if(NopComFactory.getBrowser()!=null)
		{
			NopComFactory.getBrowser().quit();
			NopComFactory.mBrowser=null;
			
		}



	}
	
	
	
}